// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import '@/utils/directives.js'
// 混合
import mixinApp from '@/mixins/app'
// 配置
import Setting from './setting'
// 插件
import plugins from '@/plugins'
// 内置组件
import iLink from '@/ui/link'
// store
import store from '@/store/index'
// 懒加载
import VueLazyload from 'vue-lazyload'
import BaiduMap from 'vue-baidu-map'
//ui框架
import ViewUI from 'view-design'

import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import 'view-design/dist/styles/iview.css'
import '@/assets/my-theme/theme.less' //自定义主题
import 'element-ui/lib/theme-chalk/index.css' // 默认主题
//图片显示大图
import VueDirectiveImagePreviewer from 'vue-directive-image-previewer'
import 'vue-directive-image-previewer/dist/assets/style.css'

Vue.use(VueDirectiveImagePreviewer)
Vue.use(BaiduMap, { ak: 'XRyPioso2jXuMlBwbcIsQnw6D6YI16ZX' })
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: require('./assets/img/no.png'),
  loading: require('./assets/img/moren.jpg'),
  attempt: 1,
  listenEvents: [
    'scroll',
    'wheel',
    'mousewheel',
    'resize',
    'animationend',
    'transitionend',
    'touchmove'
  ]
})

import Print from 'vue-print-nb'
Vue.use(Print)
//echarts
// import echarts from 'echarts'
// Vue.prototype.$echarts = echarts

window.router = router
import '@/assets/css/common.css'
Vue.use(ElementUI, { size: 'small' }) //UIElementUI
import utils from '@/utils/comm.js'
Vue.prototype.$utils = utils //utils接口

Vue.config.productionTip = false
Vue.use(VXETable)
Vue.use(plugins)
Vue.component('i-link', iLink)
Vue.use(ViewUI)
import { systemInRoutes, adminInRoutes } from '@/router/routes'

import $ from 'jquery'
window.jQuery = $
window.$ = $

new Vue({
  mixins: [mixinApp],
  router,
  store,
  render: h => h(App),
  async created () {
    // 处理路由 得到每一级的路由设置
    var domainAr = utils.urlParam()
    this.$store.dispatch('pub/page/init')
    //管理登录口
    if (domainAr.pathname.indexOf('/system') == 0) {
      // 处理路由 得到每一级的路由设置
      this.$store.commit('system/page/init', systemInRoutes)
      // siteInfo数据
      this.$store.commit('system/page/stieInfo')
      // 加载用户登录的数据
      this.$store.dispatch('system/account/load')
      // 初始化全屏监听
      this.$store.dispatch('system/layout/listenFullscreen')
      //普通管理
    } else if (domainAr.pathname.indexOf('/error') == 0) {
      //前端页面处理
    } else {
      //  this.$store.dispatch('home/page/init');
    }
  },
  watch: {
    // 监听路由 控制侧边栏显示 标记当前顶栏菜单（如需要）
    $route (to, from) {
      // const path = to.path;
      this.appRouteChange(to, from)
    }
  }
}).$mount('#app')
